using MediatR;
using Microsoft.AspNetCore.Mvc;
using Traceability.API.Dtos;
using Traceability.ErrorCode;
using System.Collections.Generic;
using System.Threading.Tasks;
using Traceability.API.APPLications.Commands.ProductShow;
using Traceability.API.APPLications.Commands.TraceabilityInfo;
using System.Security.Claims;

namespace Traceability.API.Controllers
{
    /// <summary>
    /// 商品管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        private readonly IMediator Mediator;

        public ProductController(IMediator mediator)
        {
            Mediator = mediator;
        }


        /// <summary>
        /// 获取商品列表
        /// </summary>
        /// <returns>商品列表</returns>
        [HttpGet]
        public  Task<APIResult<List<ProductDto>>> GetProductList()
        {
            ProductListQuery query = new ProductListQuery();
            return Mediator.Send(query);
        }
         /// <summary>
        /// 添加溯源信息
        /// </summary>
        [HttpPost]
        public async Task<APIResult<int>> Add(AddTraceabilityInfoCommand command)
        {
           
            return await Mediator.Send(command);
        }
    }
} 